package cn.com.fattiger.intern;

public class StringIntern {
	public static void main(String[] args){
		String str1 = "aaa";
        String str2 = "bbb";
        String str3 = "aaabbb";
        String str4 = str1 + str2;
        String str5 = "aaa" + "bbb";
        System.out.println(str3 == str4); // false
        System.out.println(str3 == str4.intern()); // true
        System.out.println(str3 == str5);// true
        String s1 = "ab123" ;  
        String s2 = new String( "ab123" ) ;  
        System.out.println( s1 == s2 );   
        String s3 = s2.intern() ;   
        System.out.println( s1 == s3 ) ;   
	}
}
